<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width: initial-scale=1.0" />
    <title>Document</title>
    <script>
      function size(n) {
        var obj = {};
        for (var i = 0; i < n.length; i++) {
            var k = n[i];
            var v = n.lastIndexOf(n[i]) - n.indexOf(n[i]) + 1;
            obj[k] = v;
        }
        console.log(obj);
        return obj;
      }

      var date = [
        "a",
        "a",
        "a",
        "b",
        "b",
        "c",
        "c",
        "c",
        "c",
        "d",
        "d",
        "d",
        "d",
      ];
      size(date);
    </script>
  </head>
  <body></body>
</html>
